package com.wft.chepter16.thread;

public class T01ExtentsThread extends Thread {
    public T01ExtentsThread() {
    }

    public T01ExtentsThread(String name) {
        super(name);
    }

    public T01ExtentsThread(ThreadGroup group, String name) {
        super(group, name);
    }

    @Override
    public void run() {
        System.out.println("hello " + Thread.currentThread().getName());
    }

    public static void main(String[] args) {
        T01ExtentsThread thread = new T01ExtentsThread();
        thread.start();
        System.out.println("thread group name :" + thread.getThreadGroup().getName());

        /**
         * 创建线程并指定线程名称
         */
        T01ExtentsThread thread2 = new T01ExtentsThread("my-thread");
        thread2.start();
        System.out.println("thread2 group name :" + thread2.getThreadGroup().getName());

        /**
         * 创建线程并指定线程所属的组
         */
        ThreadGroup threadGroup = new ThreadGroup("my-group");
        T01ExtentsThread thread3 = new T01ExtentsThread(threadGroup,"my-thread");
        thread3.start();
        System.out.println("thread3 group name :" + thread3.getThreadGroup().getName());
    }
}
